//
//  UIColor+Extension.swift
//  MattressTool
//
//  Created by Coder Yang on 2023/11/19.
//

import UIKit

extension UIColor {
    
    /// 主题颜色
    static var primary: UIColor {
        hex(0x0D81C8)
    }

    /// 次要颜色
    static var secondary: UIColor {
        primary.withAlphaComponent(0.12)
    }

    /// 背景颜色
    static var background: UIColor {
        hex(0xF3F4F6)
    }

    /// 分割线颜色
    static var separator: UIColor {
        hex(0x3C3C43).withAlphaComponent(0.36)
    }

    /// 文本颜色
    static var text: UIColor {
        hex(0x333333)
    }
    
    /// 文本颜色(灰色)
    static var textGrey: UIColor {
        .black.withAlphaComponent(0.5)
    }
    
    /// 占位颜色
    static var placeholder: UIColor {
        .black.withAlphaComponent(0.15)
    }
    
    /// 禁用
    static var disabled: UIColor {
        .black.withAlphaComponent(0.08)
    }
    
    /// 警告
    static var warning: UIColor {
        hex(0xD80000)
    }
}

extension UIColor {

    /// 十六进制颜色
     /// - Parameters:
     ///   - hexColor: 十六进制数
     ///   - alpha: 透明度（0-1 0透明 1不透明）
     /// - Returns: 颜色
    static func hex(_ hexColor: Int, alpha: CGFloat = 1.0) -> UIColor! {
        UIColor(red: ((CGFloat)((hexColor & 0xFF0000) >> 16)) / 255.0,
                        green: ((CGFloat)((hexColor & 0xFF00) >> 8)) / 255.0,
                        blue: ((CGFloat)(hexColor & 0xFF)) / 255.0,
                        alpha: alpha)
     }
}
